package com.hrserviceserve.dao;

import com.hrserviceserve.entity.Personnel;
import com.hrserviceserve.entity.Training;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface TrainingRepository extends JpaRepository<Training,Integer> {
    int deleteBytrainingID(int id);

    @Query(value = "select * from training where if(?1!='',personnel_id=?1,1=1) and if(?2!='',training_course=?2,1=1)",nativeQuery = true)
    Page<Training> findAllWhere(Integer personnelId, String trainingCourse, Pageable pageable);
}
